package me.lovatcat.springboot.demo.service.impl;

import me.lovatcat.springboot.demo.service.IAsyncService;
import me.lovetcat.common.util.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * @author acat on 2017-01-12 15:26
 */
@Service
public class AsyncService implements IAsyncService {

    private static final Logger LOG = LoggerFactory.getLogger(AsyncService.class);

    @Async
    public void testAsync(){
        LOG.info("进入异步方法-----");
        for(int i=0;i<12;i++){
            try {
                LOG.info("现在时间是 ==> {}", DateUtil.getSystemTime());
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        LOG.info("异步方法执行完毕-----");
    }

}
